TransactionAutoCompleteOnSessionClose
A
transaction runs in the context of a session initiated by invoking the
service. This attribute sets the behavior of the transaction if the
session (within the context it runs in) closes. Setting the TransactionAutoCompleteOnSessionClose
attribute to “true” will allow transactions to complete. By default,
this property is set to “false,” indicating that transactions executing
in the context of the session will be aborted, causing them to be rolled
back.
TransactionTimeout
The TransactionTimeout
attribute specifies the time by which a transaction must be completed.
If the transaction continues beyond the specified timeout interval, it
is automatically aborted and rolled back. The transaction timeout
property is subject to change and should be set in the configuration
file.
Example 3.
<behaviors> <behavior name="ServiceBehaviorAttribute" returnUnknownExceptionsAsFaults="true" TransactionTimeout="00:00:05"/> </behaviors>
|
Durable Services
A
service is considered “durable” when it can survive conditions like a
server shutdown, host recycling, and other runtime disruptions. This is
typically accomplished in a service by persisting the message and the
state of the service.
Both BizTalk Server
and Windows Workflow (WF) have support for durable and long running
services. WF implements a long-running service by providing the
developer a persistence service
that will hydrate and dehydrate workflow instances. This persistence
mechanism is extensible and allows you to create your own variation to
persist Workflow instances. (WCF implemented a similar mechanism to
persist the state of a service in .NET 3.5.)
For example, the following service contract describes a stateful, long running interaction:
Example 4.
[ServiceContract] public interface IDoWork { [OperationContract] string DoWork(string text); }
|
The interface we just defined can be annotated as a durable service by using DurableServiceBehavior and DurableOperationBehavior, as shown here:
Example 5.
[Serializable] [DurableServiceBehavior] public class DoWork : IDoWork { private string CurrentText ; [DurableOperationBehavior(CanCreateInstance = true)] string DoWork(string text); }
|
In this example, the
DoWork operation sets the instantiation and completion of a service
instance. The persistence service must be configured in order to
serialize the state of the instance. This is done by using the wsHttpContextBinding attribute in the configuration
file. .NET 3.5 introduced SQL scripts that allow for the creation of a
database that persists the service instance, similar to the process used
to persist a workflow instance . In this manner the persistence service allows the WCF service instance state to be preserved, even if the host is recycled.